package com.oracle.violet.first.until

import com.oracle.violet.first.config.ConfigHandler
import org.apache.spark.{SparkConf, SparkContext}

object SaveAPPdict {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
      .setAppName(this.getClass.getSimpleName)
      .setMaster("local[*]")
      .set("", "") //Kryo
    val sc = new SparkContext(sparkConf)

    val appDict=sc.textFile(ConfigHandler.appDictFilePath)

    val jedis = Jpools.getJedis
    val appDictData= appDict.map(_.split("\t", -1))
      .filter(_.length >= 5)
      .foreachPartition(iter => {
        val jedis = Jpools.getJedis
        iter.foreach(data => {
          val appid = data(4)
          val appname = data(1)
          jedis.hset("violet", appid, appname)
        })
        jedis.close()
      })
    sc.stop()
  }

}
